{% extends "layouts/application.html" %}
{% block content %}

<script>
function check_select_one(title_id, cbs_name){
    if(document.getElementById(title_id).checked){
        alert("请选择其中的一条记录");
        return false;
    }
    var row_cbs = document.getElementsByName(cbs_name);
    var checked_number = 0;
    var check_id;
    for(var i = 0; i < row_cbs.length; i++){
        if(row_cbs[i].checked){
			check_id = row_cbs[i].value;
            checked_number += 1;
            if(checked_number > 1){
                alert("请选择其中的一条记录");
                return false;
            }
        }
    }
    if(checked_number == 0){
        alert("请选择其中的一条记录");
        return false;
    }
    location.href='/{%site_root%}/manage/edit_levelone/'+check_id
}
</script>
<div align="center">
  <div class="boxright">
    <div class="bltop2">
      <div align="left">&nbsp;&nbsp;&nbsp;
        <strong>
          &nbsp;&nbsp;&nbsp;当前位置：&nbsp;&nbsp;
          <a href="/{%site_root%}/manage/index/">后台管理</a>&nbsp;&nbsp;
          <img src="/site_media/images/zd_arrow.gif">&nbsp;&nbsp;
          <a href="/{%site_root%}/manage/resource_sel/">资源管理</a>&nbsp;&nbsp;
          <img src="/site_media/images/zd_arrow.gif">&nbsp;&nbsp;
          <a href="/{%site_root%}/manage/setting_levelone/">一级目录管理</a>&nbsp;&nbsp;
        </strong>
      </div>
    </div>

    <div class="rep_left_height">

        <form action="" method="post"">
          <TABLE class=tatop7px cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR>
                <TD class=rtdw width="4%">
                <INPUT id="chkAll" onclick="title_check('chkAll', 'chkID')"  type=checkbox value=checkbox></TD>
                <TD class=rep_li_c width="45%"><STRONG>一级目录名称</STRONG></TD>
                <TD class=rep_li_c width="10%"><STRONG>图片地址</STRONG></TD>
                <TD class=rep_li_c width="20%"><STRONG>目录数量</STRONG></TD>
              </TR>
              {% for obj in object_list%}
                <TR id="tr_{{obj.id}}" style="TEXT-DECORATION: none" onMouseOver="this.style.backgroundColor='#EFF8FF'" onmouseout="this.style.backgroundColor=''">
                  <TD class=rtdw2>
                  <INPUT type=checkbox value="{{obj.id}}" name="chkID" onclick="rows_check('chkAll', 'chkID')">
                  <TD class=rep_li_td_bt ALIGN="left" >
                    <a href="/{%site_root%}/manage/setting_leveltwo/{{obj.id}}">{{obj.name}}</a>
                  </TD>
                  <TD class=rep_li_td_bt><a href="/site_media/{{obj.pic}}" class="imagesview"><img src="/site_media/images/picture1.png" border="0" height="16" width="16"></a></TD>
                  <TD class=rep_li_td_bt>{{obj.catalog_set.count}}</TD>
                </TR>
              {% endfor %}
            </TBODY>
          </TABLE>

          <TABLE class=tatop7px cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR>
                <TD  align="center">
                </TD>
              </TR>
            </TBODY>
          </TABLE>
          <TABLE cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR vAlign=top>
              <TR vAlign=top ALIGN="left">
                <TD>
                  <INPUT name="button" class="button" id="add" type="button" value="增加一级目录" onclick="location.href='/{%site_root%}/manage/add_levelone/'">
                  <INPUT name="button" class="button" id="edit" type="button" value="编辑目录名" onclick="return check_select_one('chkAll', 'chkID')">
                  <INPUT name="button" class="button" id="delete" type="submit" value="删除一级目录" onclick="return check_select('chkID')">
                </TD>
              </TR>
            </TBODY>
          </TABLE>
        </form>
      </div>
  </div>
</div>
{% endblock %}
